
declare cur_table cursor for select name from sysobjects where type = 'U' order by name
go

create table #out_table(txt varchar(255))
declare @name varchar(255)

open cur_table
fetch cur_table into @name

while (@@sqlstatus = 0) begin 
	insert into #out_table(txt) 
    values( "echo unloading " + @name+" ..." + char(10)+
    		"bcp %DATABASE%.." + @name + 
        	" out %OUTPUT%\data\" + @name + ".dat -S%SERVER% -U%UID% -P%PWD% -c -t "+char(1)+" -r "+char(2) + char(10))
    fetch cur_table into @name
end 
 
close cur_table
deallocate cursor cur_table
go
select txt from #out_table
go
drop table #out_table
go



